{include file="public/header" /}


<div class="page">
    <div class="fixed-bar">
        <div class="item-title">
            <div class="subject">
                <h3>App设置</h3>
                <h5></h5>
            </div>
            {include file="public/admin_items" /}
        </div>
    </div>
    <form method="post" enctype="multipart/form-data" name="form1" action="{:url('App/index')}">
        <div class="ncap-form-default">
            <div class="alioss">
                <dl>
                    <dt>客户端</dt>
                </dl>
                <dl>
                    <dt>App版本号</dt>
                    <dd>
                        <input id="user_app_edition" name="user_app_edition" value="{$config.user_app_edition|default=''}"
                               class="input-txt" type="text"><span></span>
                    </dd>
                </dl>
                <dl>
                    <dt>App更新链接：</dt>
                    <dd>
                        <input id="user_app_down_url" name="user_app_down_url" value="{$config.user_app_down_url|default=''}"
                               class="input-txt" type="text"><span></span>
                    </dd>
                </dl>
                <dl>
                    <dt>服务端</dt>
                </dl>
                <dl>
                    <dt>App版本号</dt>
                    <dd>
                        <input id="server_app_edition" name="server_app_edition" value="{$config.server_app_edition|default=''}"
                               class="input-txt" type="text"><span></span>
                    </dd>
                </dl>
                <dl>
                    <dt>App更新链接：</dt>
                    <dd>
                        <input id="server_app_down_url" name="server_app_down_url" value="{$config.server_app_down_url|default=''}"
                               class="input-txt" type="text"><span></span>
                    </dd>
                </dl>
            </div>
            <dl>
                <dt></dt>
                <dd><input class="btn" type="submit" style='line-height: 30px;' value="{$Think.lang.ds_submit}"/></dd>
            </dl>
        </div>
    </form>
</div>
<script>


    $(document).ready(function () {
        $('#form1').validate({
            errorPlacement: function (error, element) {
                   error.appendTo(element.parent().parent().find('span'));
            },
            rules: {
                user_app_edition: {
                    required: true,
                },
                user_app_down_url: {
                    required: true,
                },
                server_app_edition: {
                    required: true,
                },
                server_app_down_url: {
                    required: true,
                },

            },
            messages: {
                user_app_edition: {
                    required: "不能为空",

                },
                user_app_down_url: {
                    required: "不能为空",

                },
                server_app_edition: {
                    required: "不能为空",

                },
                server_app_down_url: {
                    required: "不能为空",

                },
            }
        });


        $('form').submit(function () {
            var res = $(this).valid();
            if (res) {
                var url = $('form').attr('action');
                $.ajax({
                    type: "POST",
                    url: url,
                    data: $('form').serialize(),
                    error: function (request) {
                        alert("Connection error");
                    },
                    success: function (result) {
                        // alert(result) ;return false;
                        if (result.code == 0) {
                            layer.msg(result.msg);
                            setTimeout(() => {
                                location.href = result.url;
                                return false;
                            }, 1000)

                        } else {
                            layer.msg(result.msg);
                            setTimeout(() => {
                                location.href = result.url;
                                return false;
                            }, 1000)


                        }
                    }
                });
                return false;


            } else {
                return false;
            }
            return false;

        });
    });
</script>